<?php
namespace app\modules\content\models;

use yii\db\ActiveRecord;
use yii;

class IeltsWriteAnswer extends ActiveRecord
{
    public static function tableName()
    {
        return '{{%ielts_write_answer}}';
    }

    public function rules()
    {
        return [
            // username and password are both required
            // [['pic', 'url'], 'required'],

        ];
    }

    /**
     * [isSubmit description]
     * @Author don
     * @Date   2022-03-14
     * @param  [type]     $id [description]
     * @return boolean        [description]
     */
    public static function isSubmit($id)
    {
        $uid = Yii::$app->session->get('uid');
        // $uid=3;
        if (!$uid) {
            return 0;
        }
        $res = self::find()->where(['pid'=>$id, 'uid'=>$uid])->one();
        if (!$res) {
            return 0;
        }

        return 1;
    }
}